﻿<%@ Page Title="Title" Language="C#" Inherits="System.Web.Mvc.ViewPage<System.Collections.Generic.IEnumerable<Uber.Core.Model.Purchase>>" MasterPageFile="~/Views/Shared/Site.Master" %>
<asp:Content runat="server" ID="Title" ContentPlaceHolderID="TitleContent"></asp:Content>
<asp:Content runat="server" ID="Main" ContentPlaceHolderID="MainContent">
<h1>My Purchases</h1>
<%if(Model.Count() == 0) {%>
you don't have any purchases yet
<%}%>
<ul id="mypurchases" class="tt">
<%foreach(var o in Model)
  {%>
   <li>
   <div>
   <table>
   <thead><tr><td>Title</td><td>Version</td><td>Quantity</td><td>Date</td></tr></thead>
   <tbody><tr><td><%=o.ProductVersion.Product.Title %></td><td><%=o.ProductVersion.VersionNumber %></td><td><%=o.Quantity %></td><td><%=o.DateCreated.ToLocalTime() %></td></tr></tbody>
   </table> 
    
   <table>
   <thead><tr><td>Code</td><td>Key</td><td>Version</td></tr></thead><tbody>
   <% foreach(var l in o.Licenses){%>
   <tr><td><%=l.Code %></td><td><%=l.Key %></td><td><%=l.ProductVersion.VersionNumber %></td></tr>     
   <%} %>
   </tbody>
   </table>   
  
   </div>
   </li>
<%} %>
</ul>

<h2>Downloads</h2>
<div class="tt">
<table>
<thead>
<tr><td>Title</td><td>Version</td><td></td></tr>
</thead>
<% var productVersions = Model.SelectMany(o => o.Licenses).Select(d => d.ProductVersion).Distinct();
   foreach(var pv in productVersions)
   {
     %>
     <tr><td><%=pv.Product.Title %></td><td><%=pv.VersionNumber %></td><td><form method="post" action="<%=Url.Action("Download",new{ id = pv.Id}) %>"><input type="submit" value="Download" /></form></td>
     </tr>
     <%  
   }
%>
</table>
</div>
<br/>
<div class="hinfo">
(it takes some time to process the transaction so if you don't see here a recent purchase give it a bit of time)
</div>

</asp:Content>
